<%@page import="model.Items"%>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
	pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Items</title>
<link type="text/css" href="JSP/css/style.css" rel="stylesheet"></link>
</head>
<%@include file="../checkSession.jsp"%>
<%@page import="java.util.LinkedList"%>
<%@page import="model.Sales"%>
<%!LinkedList<Items> list = new LinkedList<Items>();
	LinkedList<String> list1 = new LinkedList<String>();
	String owner;%>
<%
	list = (LinkedList<Items>) request.getAttribute("lstItem");
	list1 = (LinkedList<String>) request.getAttribute("lstOwner");
	owner = (String) request.getAttribute("owner");
	if (list == null) {
		out.println("NULL");
	} else {

		for (int i = 0; i < list1.size(); i++) {
			String s = list1.get(i);
			if (s.equalsIgnoreCase(owner)) {
				list1.remove(i);
				list1.addFirst(owner);
				break;
			}

		}
%>
<body>
	<div id="wrap">
		<%@include file="adminHeader.jsp"%>
		<font size="3" face="verdana" color="orange">Items Tables</font>
		<div class="center_content">
			<div class="left_content">
				<form name="input" action="serverlet_enable_disable_user_auditing"
					method="post">
					Table: <select name="Table"
						onchange="window.location.href=this.value">
						<%
							String u;
								for (int i = 0; i < list1.size(); i++) {
									u = list1.get(i);
									if ("admin".equalsIgnoreCase(u)) {
						%>
						<option value=<%="./ViewItemTable?owner=" + u%>><%=u + ".Item"%></option>
						<%
							} else {
						%>
						<option value=<%="./ViewSaleReportTable?owner=" + u%>><%=u + ".SaleReport"%></option>
						<%
							}
								}
						%>
					</select>
				</form>
				<form name="input"
					action="./DMLItemTable?mode=insert&owner=<%=owner%>" method="post">
					<input type="submit" value="Insert" />
				</form>
				<form name="input"
					action="./DMLItemTable?mode=update&owner=<%=owner%>" method="post">
					<input type="submit" value="Update" />
				</form>
				<form name="input"
					action="./DMLItemTable?mode=delete&owner=<%=owner%>" method="post">
					<input type="submit" value="Delete" /><br>
				</form>
			</div>
			<div class="right_content">
				<table border=1>
					<tr>
						<th class="table-header-repeat line-left">_Item_ID_</th>
						<th class="table-header-repeat line-left">_Item_Name_</th>
						<th class="table-header-repeat line-left">_Price_</th>
					</tr>
					<%
						for (int i = 0; i < list.size(); i++) {
								Items s = list.get(i);
					%>
					<tr>
						<td><%=s.itemId%></td>
						<td><%=s.itemName%></td>
						<td><%=s.price%></td>
					</tr>
					<%
						}
						}
					%>
				</table>
			</div>
		</div>

	</div>
</body>


</html>